package org.dromara.system.controller.system;


import lombok.extern.slf4j.Slf4j;
import org.dromara.bean.domain.HisDelivery;
import org.dromara.common.core.domain.R;
import org.dromara.system.service.ISysHisDeliveryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @Description: 物流公司
 * @Author: jeecg-boot
 * @Date: 2022-04-23
 * @Version: V1.0
 */
@Slf4j
@RestController
@RequestMapping("/system/delivery")
public class HisDeliveryController {
    @Autowired
    private ISysHisDeliveryService sysHisDeliveryService;

    /**
     * 分页列表查询
     *
     * @param dvyName 物流公司名称
     * @return
     */
    @GetMapping(value = "/listByDvyName")
    public R<?> listByDvyName(@RequestParam(name = "dvyName", required = false) String dvyName) {
        return sysHisDeliveryService.listByDvyName(dvyName);
    }

    /**
     * 物流公司-全部物流公司
     */
    @GetMapping(value = "/allList")
    public R<?> allList() {
        return sysHisDeliveryService.allList();
    }

    /**
     * 物流公司-分页列表查询
     *
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    @GetMapping(value = "/list")
    public R<?> queryPageList(HisDelivery hisDelivery,
                              @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                              @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                              HttpServletRequest req) {
        return sysHisDeliveryService.queryPageList(hisDelivery, pageNo, pageSize, req);
    }

    /**
     * 添加
     *
     * @param hisDelivery
     * @return
     */

    @PostMapping(value = "/add")
    public R<?> add(@RequestBody HisDelivery hisDelivery) {
        return sysHisDeliveryService.add(hisDelivery);
    }

    /**
     * 编辑
     *
     * @param hisDelivery
     * @return
     */
    @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
    public R<?> edit(@RequestBody HisDelivery hisDelivery) {
        return sysHisDeliveryService.edit(hisDelivery);
    }

    /**
     * 通过id删除
     *
     * @param id
     * @return
     */
    @DeleteMapping(value = "/delete")
    public R<?> delete(@RequestParam(name = "id", required = true) String id) {
        return sysHisDeliveryService.delete(id);
    }

    /**
     * 批量删除
     *
     * @param ids
     * @return
     */
    @DeleteMapping(value = "/deleteBatch")
    public R<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
        return sysHisDeliveryService.deleteBatch(ids);
    }

    /**
     * 通过id查询
     *
     * @param id
     * @return
     */
    @GetMapping(value = "/queryById")
    public R<?> queryById(@RequestParam(name = "id", required = true) String id) {
        return sysHisDeliveryService.queryById(id);
    }

//    /**
//     * 导出excel
//     *
//     * @param request
//     * @param hisDelivery
//     */
//    @RequestMapping(value = "/exportXls")
//    public ModelAndView exportXls(HttpServletRequest request, HisDelivery hisDelivery) {
//        return super.exportXls(request, hisDelivery, HisDelivery.class, "物流公司");
//    }
//
//    /**
//     * 通过excel导入数据
//     *
//     * @param request
//     * @param response
//     * @return
//     */
//    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
//    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
//        return super.importExcel(request, response, HisDelivery.class);
//    }

}
